0 CpxTRS
↳1 TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID), 0 ms)
↳2 CpxWeightedTrs
↳3 TypeInferenceProof (BOTH BOUNDS(ID, ID), 0 ms)
↳4 CpxTypedWeightedTrs
↳5 CompletionProof (UPPER BOUND(ID), 0 ms)
↳6 CpxTypedWeightedCompleteTrs
↳7 CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID), 0 ms)
↳8 CpxRNTS
↳9 CompleteCoflocoProof (⇔, 594 ms)
↳10 BOUNDS(1, n^3)
minus(x, 0) → x
minus(s(x), s(y)) → minus(x, y)
quot(0, s(y)) → 0
quot(s(x), s(y)) → s(quot(minus(x, y), s(y)))
app(nil, y) → y
app(add(n, x), y) → add(n, app(x, y))
reverse(nil) → nil
reverse(add(n, x)) → app(reverse(x), add(n, nil))
shuffle(nil) → nil
shuffle(add(n, x)) → add(n, shuffle(reverse(x)))
concat(leaf, y) → y
concat(cons(u, v), y) → cons(u, concat(v, y))
less_leaves(x, leaf) → false
less_leaves(leaf, cons(w, z)) → true
less_leaves(cons(u, v), cons(w, z)) → less_leaves(concat(u, v), concat(w, z))
minus(x, 0) → x [1]
minus(s(x), s(y)) → minus(x, y) [1]
quot(0, s(y)) → 0 [1]
quot(s(x), s(y)) → s(quot(minus(x, y), s(y))) [1]
app(nil, y) → y [1]
app(add(n, x), y) → add(n, app(x, y)) [1]
reverse(nil) → nil [1]
reverse(add(n, x)) → app(reverse(x), add(n, nil)) [1]
shuffle(nil) → nil [1]
shuffle(add(n, x)) → add(n, shuffle(reverse(x))) [1]
concat(leaf, y) → y [1]
concat(cons(u, v), y) → cons(u, concat(v, y)) [1]
less_leaves(x, leaf) → false [1]
less_leaves(leaf, cons(w, z)) → true [1]
less_leaves(cons(u, v), cons(w, z)) → less_leaves(concat(u, v), concat(w, z)) [1]
minus(x, 0) → x [1]
minus(s(x), s(y)) → minus(x, y) [1]
quot(0, s(y)) → 0 [1]
quot(s(x), s(y)) → s(quot(minus(x, y), s(y))) [1]
app(nil, y) → y [1]
app(add(n, x), y) → add(n, app(x, y)) [1]
reverse(nil) → nil [1]
reverse(add(n, x)) → app(reverse(x), add(n, nil)) [1]
shuffle(nil) → nil [1]
shuffle(add(n, x)) → add(n, shuffle(reverse(x))) [1]
concat(leaf, y) → y [1]
concat(cons(u, v), y) → cons(u, concat(v, y)) [1]
less_leaves(x, leaf) → false [1]
less_leaves(leaf, cons(w, z)) → true [1]
less_leaves(cons(u, v), cons(w, z)) → less_leaves(concat(u, v), concat(w, z)) [1]
minus :: 0:s → 0:s → 0:s 0 :: 0:s s :: 0:s → 0:s quot :: 0:s → 0:s → 0:s app :: nil:add → nil:add → nil:add nil :: nil:add add :: a → nil:add → nil:add reverse :: nil:add → nil:add shuffle :: nil:add → nil:add concat :: leaf:cons → leaf:cons → leaf:cons leaf :: leaf:cons cons :: leaf:cons → leaf:cons → leaf:cons less_leaves :: leaf:cons → leaf:cons → false:true false :: false:true true :: false:true |
minus(v0, v1) → null_minus [0]
quot(v0, v1) → null_quot [0]
null_minus, null_quot, const
Runtime Complexity Weighted TRS with Types. The TRS R consists of the following rules:
The TRS has the following type information:
Rewrite Strategy: INNERMOST |
0 => 0
nil => 0
leaf => 0
false => 0
true => 1
null_minus => 0
null_quot => 0
const => 0
app(z', z'') -{ 1 }→ y :|: z'' = y, y >= 0, z' = 0
app(z', z'') -{ 1 }→ 1 + n + app(x, y) :|: n >= 0, z'' = y, z' = 1 + n + x, x >= 0, y >= 0
concat(z', z'') -{ 1 }→ y :|: z'' = y, y >= 0, z' = 0
concat(z', z'') -{ 1 }→ 1 + u + concat(v, y) :|: v >= 0, z' = 1 + u + v, z'' = y, y >= 0, u >= 0
less_leaves(z', z'') -{ 1 }→ less_leaves(concat(u, v), concat(w, z)) :|: v >= 0, z >= 0, z' = 1 + u + v, z'' = 1 + w + z, w >= 0, u >= 0
less_leaves(z', z'') -{ 1 }→ 1 :|: z >= 0, z'' = 1 + w + z, w >= 0, z' = 0
less_leaves(z', z'') -{ 1 }→ 0 :|: z'' = 0, z' = x, x >= 0
minus(z', z'') -{ 1 }→ x :|: z'' = 0, z' = x, x >= 0
minus(z', z'') -{ 1 }→ minus(x, y) :|: z' = 1 + x, x >= 0, y >= 0, z'' = 1 + y
minus(z', z'') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z'' = v1, z' = v0
quot(z', z'') -{ 1 }→ 0 :|: y >= 0, z'' = 1 + y, z' = 0
quot(z', z'') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z'' = v1, z' = v0
quot(z', z'') -{ 1 }→ 1 + quot(minus(x, y), 1 + y) :|: z' = 1 + x, x >= 0, y >= 0, z'' = 1 + y
reverse(z') -{ 1 }→ app(reverse(x), 1 + n + 0) :|: n >= 0, z' = 1 + n + x, x >= 0
reverse(z') -{ 1 }→ 0 :|: z' = 0
shuffle(z') -{ 1 }→ 0 :|: z' = 0
shuffle(z') -{ 1 }→ 1 + n + shuffle(reverse(x)) :|: n >= 0, z' = 1 + n + x, x >= 0
eq(start(V, V1),0,[minus(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1),0,[quot(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1),0,[app(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1),0,[reverse(V, Out)],[V >= 0]). eq(start(V, V1),0,[shuffle(V, Out)],[V >= 0]). eq(start(V, V1),0,[concat(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1),0,[fun(V, V1, Out)],[V >= 0,V1 >= 0]). eq(minus(V, V1, Out),1,[],[Out = V2,V1 = 0,V = V2,V2 >= 0]). eq(minus(V, V1, Out),1,[minus(V3, V4, Ret)],[Out = Ret,V = 1 + V3,V3 >= 0,V4 >= 0,V1 = 1 + V4]). eq(quot(V, V1, Out),1,[],[Out = 0,V5 >= 0,V1 = 1 + V5,V = 0]). eq(quot(V, V1, Out),1,[minus(V6, V7, Ret10),quot(Ret10, 1 + V7, Ret1)],[Out = 1 + Ret1,V = 1 + V6,V6 >= 0,V7 >= 0,V1 = 1 + V7]). eq(app(V, V1, Out),1,[],[Out = V8,V1 = V8,V8 >= 0,V = 0]). eq(app(V, V1, Out),1,[app(V10, V11, Ret11)],[Out = 1 + Ret11 + V9,V9 >= 0,V1 = V11,V = 1 + V10 + V9,V10 >= 0,V11 >= 0]). eq(reverse(V, Out),1,[],[Out = 0,V = 0]). eq(reverse(V, Out),1,[reverse(V12, Ret0),app(Ret0, 1 + V13 + 0, Ret2)],[Out = Ret2,V13 >= 0,V = 1 + V12 + V13,V12 >= 0]). eq(shuffle(V, Out),1,[],[Out = 0,V = 0]). eq(shuffle(V, Out),1,[reverse(V15, Ret101),shuffle(Ret101, Ret12)],[Out = 1 + Ret12 + V14,V14 >= 0,V = 1 + V14 + V15,V15 >= 0]). eq(concat(V, V1, Out),1,[],[Out = V16,V1 = V16,V16 >= 0,V = 0]). eq(concat(V, V1, Out),1,[concat(V18, V19, Ret13)],[Out = 1 + Ret13 + V17,V18 >= 0,V = 1 + V17 + V18,V1 = V19,V19 >= 0,V17 >= 0]). eq(fun(V, V1, Out),1,[],[Out = 0,V1 = 0,V = V20,V20 >= 0]). eq(fun(V, V1, Out),1,[],[Out = 1,V21 >= 0,V1 = 1 + V21 + V22,V22 >= 0,V = 0]). eq(fun(V, V1, Out),1,[concat(V23, V24, Ret01),concat(V25, V26, Ret14),fun(Ret01, Ret14, Ret3)],[Out = Ret3,V24 >= 0,V26 >= 0,V = 1 + V23 + V24,V1 = 1 + V25 + V26,V25 >= 0,V23 >= 0]). eq(minus(V, V1, Out),0,[],[Out = 0,V27 >= 0,V28 >= 0,V1 = V28,V = V27]). eq(quot(V, V1, Out),0,[],[Out = 0,V29 >= 0,V30 >= 0,V1 = V30,V = V29]). input_output_vars(minus(V,V1,Out),[V,V1],[Out]). input_output_vars(quot(V,V1,Out),[V,V1],[Out]). input_output_vars(app(V,V1,Out),[V,V1],[Out]). input_output_vars(reverse(V,Out),[V],[Out]). input_output_vars(shuffle(V,Out),[V],[Out]). input_output_vars(concat(V,V1,Out),[V,V1],[Out]). input_output_vars(fun(V,V1,Out),[V,V1],[Out]). |
CoFloCo proof output:
Preprocessing Cost Relations
=====================================
#### Computed strongly connected components
0. recursive : [app/3]
1. recursive : [concat/3]
2. recursive : [fun/3]
3. recursive : [minus/3]
4. recursive : [quot/3]
5. recursive [non_tail] : [reverse/2]
6. recursive : [shuffle/2]
7. non_recursive : [start/2]
#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into app/3
1. SCC is partially evaluated into concat/3
2. SCC is partially evaluated into fun/3
3. SCC is partially evaluated into minus/3
4. SCC is partially evaluated into quot/3
5. SCC is partially evaluated into reverse/2
6. SCC is partially evaluated into shuffle/2
7. SCC is partially evaluated into start/2
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations app/3
* CE 16 is refined into CE [26]
* CE 15 is refined into CE [27]
### Cost equations --> "Loop" of app/3
* CEs [27] --> Loop 18
* CEs [26] --> Loop 19
### Ranking functions of CR app(V,V1,Out)
* RF of phase [19]: [V]
#### Partial ranking functions of CR app(V,V1,Out)
* Partial RF of phase [19]:
- RF of loop [19:1]:
V
### Specialization of cost equations concat/3
* CE 22 is refined into CE [28]
* CE 21 is refined into CE [29]
### Cost equations --> "Loop" of concat/3
* CEs [29] --> Loop 20
* CEs [28] --> Loop 21
### Ranking functions of CR concat(V,V1,Out)
* RF of phase [21]: [V]
#### Partial ranking functions of CR concat(V,V1,Out)
* Partial RF of phase [21]:
- RF of loop [21:1]:
V
### Specialization of cost equations fun/3
* CE 25 is refined into CE [30,31,32,33]
* CE 23 is refined into CE [34]
* CE 24 is refined into CE [35]
### Cost equations --> "Loop" of fun/3
* CEs [34] --> Loop 22
* CEs [35] --> Loop 23
* CEs [30,31,32,33] --> Loop 24
### Ranking functions of CR fun(V,V1,Out)
* RF of phase [24]: [V,V1]
#### Partial ranking functions of CR fun(V,V1,Out)
* Partial RF of phase [24]:
- RF of loop [24:1]:
V
V1
### Specialization of cost equations minus/3
* CE 11 is refined into CE [36]
* CE 9 is refined into CE [37]
* CE 10 is refined into CE [38]
### Cost equations --> "Loop" of minus/3
* CEs [38] --> Loop 25
* CEs [36] --> Loop 26
* CEs [37] --> Loop 27
### Ranking functions of CR minus(V,V1,Out)
* RF of phase [25]: [V,V1]
#### Partial ranking functions of CR minus(V,V1,Out)
* Partial RF of phase [25]:
- RF of loop [25:1]:
V
V1
### Specialization of cost equations quot/3
* CE 12 is refined into CE [39]
* CE 14 is refined into CE [40]
* CE 13 is refined into CE [41,42,43]
### Cost equations --> "Loop" of quot/3
* CEs [43] --> Loop 28
* CEs [42] --> Loop 29
* CEs [41] --> Loop 30
* CEs [39,40] --> Loop 31
### Ranking functions of CR quot(V,V1,Out)
* RF of phase [28]: [V-1,V-V1+1]
* RF of phase [30]: [V]
#### Partial ranking functions of CR quot(V,V1,Out)
* Partial RF of phase [28]:
- RF of loop [28:1]:
V-1
V-V1+1
* Partial RF of phase [30]:
- RF of loop [30:1]:
V
### Specialization of cost equations reverse/2
* CE 18 is refined into CE [44,45]
* CE 17 is refined into CE [46]
### Cost equations --> "Loop" of reverse/2
* CEs [46] --> Loop 32
* CEs [45] --> Loop 33
* CEs [44] --> Loop 34
### Ranking functions of CR reverse(V,Out)
* RF of phase [33]: [V]
#### Partial ranking functions of CR reverse(V,Out)
* Partial RF of phase [33]:
- RF of loop [33:1]:
V
### Specialization of cost equations shuffle/2
* CE 20 is refined into CE [47,48]
* CE 19 is refined into CE [49]
### Cost equations --> "Loop" of shuffle/2
* CEs [49] --> Loop 35
* CEs [48] --> Loop 36
* CEs [47] --> Loop 37
### Ranking functions of CR shuffle(V,Out)
* RF of phase [36]: [V-1]
#### Partial ranking functions of CR shuffle(V,Out)
* Partial RF of phase [36]:
- RF of loop [36:1]:
V-1
### Specialization of cost equations start/2
* CE 2 is refined into CE [50,51,52]
* CE 3 is refined into CE [53,54,55,56,57]
* CE 4 is refined into CE [58,59]
* CE 5 is refined into CE [60,61]
* CE 6 is refined into CE [62,63]
* CE 7 is refined into CE [64,65]
* CE 8 is refined into CE [66,67,68,69]
### Cost equations --> "Loop" of start/2
* CEs [53,61,63] --> Loop 38
* CEs [50,51,52,54,55,56,57,59,65,67,68,69] --> Loop 39
* CEs [58,60,62,64,66] --> Loop 40
### Ranking functions of CR start(V,V1)
#### Partial ranking functions of CR start(V,V1)
Computing Bounds
=====================================
#### Cost of chains of app(V,V1,Out):
* Chain [[19],18]: 1*it(19)+1
Such that:it(19) =< -V1+Out
with precondition: [V+V1=Out,V>=1,V1>=0]
* Chain [18]: 1
with precondition: [V=0,V1=Out,V1>=0]
#### Cost of chains of concat(V,V1,Out):
* Chain [[21],20]: 1*it(21)+1
Such that:it(21) =< -V1+Out
with precondition: [V+V1=Out,V>=1,V1>=0]
* Chain [20]: 1
with precondition: [V=0,V1=Out,V1>=0]
#### Cost of chains of fun(V,V1,Out):
* Chain [[24],23]: 3*it(24)+2*s(9)+2*s(10)+1
Such that:aux(6) =< V1
aux(7) =< V
it(24) =< aux(7)
it(24) =< aux(6)
s(11) =< it(24)*aux(6)
s(12) =< it(24)*aux(7)
s(10) =< s(12)
s(9) =< s(11)
with precondition: [Out=1,V>=1,V1>=V+1]
* Chain [[24],22]: 3*it(24)+2*s(9)+2*s(10)+1
Such that:aux(5) =< V
aux(8) =< V1
it(24) =< aux(8)
it(24) =< aux(5)
s(11) =< it(24)*aux(8)
s(12) =< it(24)*aux(5)
s(10) =< s(12)
s(9) =< s(11)
with precondition: [Out=0,V1>=1,V>=V1]
* Chain [23]: 1
with precondition: [V=0,Out=1,V1>=1]
* Chain [22]: 1
with precondition: [V1=0,Out=0,V>=0]
#### Cost of chains of minus(V,V1,Out):
* Chain [[25],27]: 1*it(25)+1
Such that:it(25) =< V1
with precondition: [V=Out+V1,V1>=1,V>=V1]
* Chain [[25],26]: 1*it(25)+0
Such that:it(25) =< V1
with precondition: [Out=0,V>=1,V1>=1]
* Chain [27]: 1
with precondition: [V1=0,V=Out,V>=0]
* Chain [26]: 0
with precondition: [Out=0,V>=0,V1>=0]
#### Cost of chains of quot(V,V1,Out):
* Chain [[30],31]: 2*it(30)+1
Such that:it(30) =< Out
with precondition: [V1=1,Out>=1,V>=Out]
* Chain [[30],29,31]: 2*it(30)+1*s(14)+2
Such that:s(14) =< 1
it(30) =< Out
with precondition: [V1=1,Out>=2,V>=Out]
* Chain [[28],31]: 2*it(28)+1*s(17)+1
Such that:it(28) =< V-V1+1
aux(11) =< V
it(28) =< aux(11)
s(17) =< aux(11)
with precondition: [V1>=2,Out>=1,V+2>=2*Out+V1]
* Chain [[28],29,31]: 2*it(28)+1*s(14)+1*s(17)+2
Such that:it(28) =< V-V1+1
s(14) =< V1
aux(12) =< V
it(28) =< aux(12)
s(17) =< aux(12)
with precondition: [V1>=2,Out>=2,V+3>=2*Out+V1]
* Chain [31]: 1
with precondition: [Out=0,V>=0,V1>=0]
* Chain [29,31]: 1*s(14)+2
Such that:s(14) =< V1
with precondition: [Out=1,V>=1,V1>=1]
#### Cost of chains of reverse(V,Out):
* Chain [[33],34,32]: 2*it(33)+1*s(23)+3
Such that:aux(16) =< Out
it(33) =< aux(16)
s(23) =< it(33)*aux(16)
with precondition: [Out=V,Out>=2]
* Chain [34,32]: 3
with precondition: [V=Out,V>=1]
* Chain [32]: 1
with precondition: [V=0,Out=0]
#### Cost of chains of shuffle(V,Out):
* Chain [[36],37,35]: 4*it(36)+2*s(33)+1*s(34)+3
Such that:aux(19) =< Out
it(36) =< aux(19)
aux(17) =< aux(19)
s(35) =< it(36)*aux(17)
s(33) =< s(35)
s(34) =< s(33)*aux(19)
with precondition: [V=Out,V>=2]
* Chain [37,35]: 3
with precondition: [V=Out,V>=1]
* Chain [35]: 1
with precondition: [V=0,Out=0]
#### Cost of chains of start(V,V1):
* Chain [40]: 1
with precondition: [V=0]
* Chain [39]: 4*s(42)+4*s(45)+4*s(47)+6*s(56)+4*s(59)+4*s(60)+2
Such that:aux(20) =< V
aux(21) =< V-V1+1
aux(22) =< V1
s(47) =< aux(20)
s(45) =< aux(21)
s(42) =< aux(22)
s(45) =< aux(20)
s(56) =< aux(22)
s(56) =< aux(20)
s(57) =< s(56)*aux(22)
s(58) =< s(56)*aux(20)
s(59) =< s(58)
s(60) =< s(57)
with precondition: [V>=0,V1>=0]
* Chain [38]: 1*s(68)+10*s(70)+1*s(73)+2*s(78)+1*s(79)+3
Such that:s(68) =< 1
aux(23) =< V
s(70) =< aux(23)
s(73) =< s(70)*aux(23)
s(76) =< aux(23)
s(77) =< s(70)*s(76)
s(78) =< s(77)
s(79) =< s(78)*aux(23)
with precondition: [V>=1]
Closed-form bounds of start(V,V1):
-------------------------------------
* Chain [40] with precondition: [V=0]
- Upper bound: 1
- Complexity: constant
* Chain [39] with precondition: [V>=0,V1>=0]
- Upper bound: 4*V+2+4*V*V1+10*V1+4*V1*V1+nat(V-V1+1)*4
- Complexity: n^2
* Chain [38] with precondition: [V>=1]
- Upper bound: 10*V+4+3*V*V+V*V*V
- Complexity: n^3
### Maximum cost of start(V,V1): 4*V+1+max([6*V+2+3*V*V+V*V*V,4*V*nat(V1)+nat(V1)*10+nat(V1)*4*nat(V1)+nat(V-V1+1)*4])+1
Asymptotic class: n^3
* Total analysis performed in 475 ms.